﻿/**
*业务员变更
*/
Chenxin.UI.ChgEmpForm = Chenxin.extend(Chenxin.UI.FormCommon,{
    actionUrl:'/service/logic/ShowListIntent.ashx',
    id:'ChgEmp',
    renderTo:'divChgEmp',
    winCls:'',
    jqmWidth:400,
    defBBtn:true,
    createForm: function() {
        return Chenxin.FormCommon.ChgEmpForm(this.id);
    },
    initEvent: function() {
        var _this = this;
        var thisid='#'+this.id;	
		_this.isclick = true;
		
		$(thisid+'_save').live('click',function(){			
		    if(_this.isclick)
		    {
			    _this.save();
			}
		});
		$(thisid+'_cancle').live('click',function(){			
			_this.hide();
		});
		
		/*************事件：领用日期得到焦点*************/
        $("#LastEmployeeGetTime").focus(function(){
            WdatePicker({
                dateFmt:'yyyy-MM-dd',
                oncleared:function(){
                            $(this).blur();
                          },
                onpicked:function(){
                            $(this).blur();
                         }
            });
        });
    },
    createComboList:function(){
        //领用部门
        var comboBelongDepartId = new Chenxin.UI.StructCombo({
            param: { op: 'getcontroldeparts' },
            containerId: '#'+this.id+'_BelongDepartId',
            name: 'BelongDepartId',
            inModelType: 'all',
            txtModelName: 'BelongDepart',
            required: true,
            tbxWidth: 129,
			colNum:4,
			pageSize:12,
			hasSearch:true,
			hasPage:true,
            onSelected: function() {
                if( this.getValue() != this.defVal ){
					comboLastEmployeeId.loadUser(this.getValue());
				}
				if( this.getValue() != this.defVal ){
					comboBelongEmpId.loadUser(this.getValue());
				}
            },
            afterSetValue: function(newVal, oldVal) {
                if( newVal != "请选择" ){
			       comboLastEmployeeId.loadUser(newVal);
				}
				if( newVal != "请选择" ){
			       comboBelongEmpId.loadUser(newVal);
				}
            }
        });
        //领用人员
        var comboLastEmployeeId = new Chenxin.UI.RichModelTreeCombo({
            textBoxId: this.id+'_LastEmployeeId',
            inModelType: 'all',
            txtModelName: 'LastEmployee',
            required: true,
            singleSelect: true,
            name: 'LastEmployeeId'
        });
        //下发人员
		var comboBelongEmpId =new Chenxin.UI.RichModelTreeCombo({
            textBoxId:this.id+'_BelongEmpId',
            containerId:'#BelongEmpId',
            inModelType:'all',
			txtModelName:'BelongEmp',
            required:true,
            singleSelect:true,
			name:'BelongEmpId'
        });
        return [comboBelongDepartId,comboLastEmployeeId,comboBelongEmpId];
    },
    saveSucc: function() {
        this.reloadGrid();
    },
    initComponent: function() {
        Chenxin.UI.ChgEmpForm.superclass.initComponent.call(this);
    }
});

Chenxin.FormCommon.ChgEmpForm=function(formID){
return '<table class="tbl_f"><tr><th style="width:130px;">意向书编号：</th><td><input type="hidden"  name="IntentionId" /><input name="IntentionCode" class="inputbox_n fl" type="text" readonly="readonly" style="width:160px;"/></td></tr><tr><th>领用日期：</th><td><input type="text" id="LastEmployeeGetTime" name="LastEmployeeGetTime" class="inputbox_n fl" readonly="readonly" style="width:160px" /></td><tr><th>原秘书：</th><td><input id="PrimaryBelongEmp" name="PrimaryBelongEmp" class="inputbox_n fl" readonly="readonly" style="width:160px;"></td></td><tr><th>原领用人员：</th><td><input id="PrimaryEmployee" name="PrimaryEmployee" class="inputbox_n fl" readonly="readonly" style="width:160px;"></td></tr><tr><th>领用部门：</th><td><div id="'+formID+'_BelongDepartId"style="z-index:1; margin-right: 2px;" class="SelectWrapSingle"></div></td></td><tr><th>秘书：</th><td><input type="text" class="inputbox_n fl" id="'+formID+'_BelongEmpId" style="width:160px;"/></td></tr><tr><th>领用人员：</th><td><input type="text" class="inputbox_n fl" id="'+formID+'_LastEmployeeId" style="width:160px;"/></td></tr></table>';
};